//
//  ClientView.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/6/10.
//

import UIKit

protocol ClientViewDelegate:class {
    func homeViewAcrionDelegate(actonType:HomeViewActonType) 
}

class ClientView: UIView {

    var clientDic:Dictionary<String, Any>!
    weak var delegate:ClientViewDelegate?

    
    @IBOutlet weak var statisticsTitleLab: UILabel!
    @IBOutlet weak var monthLab: UILabel!
    @IBOutlet weak var monthNumLab: UILabel!
    @IBOutlet weak var storageLab: UILabel!
    @IBOutlet weak var storageNumLab: UILabel!
    @IBOutlet weak var dayLab: UILabel!
    @IBOutlet weak var dayNumLab: UILabel!
    @IBOutlet weak var dayFreightLab: UILabel!
    @IBOutlet weak var dayFreightNumLab: UILabel!
    @IBOutlet weak var dayQuitLab: UILabel!
    @IBOutlet weak var dayQuitNumLab: UILabel!
    @IBOutlet weak var daycollectLab: UILabel!
    @IBOutlet weak var daycollecNumLab: UILabel!
    @IBOutlet weak var lineView: UIView!
    @IBOutlet weak var twoLineView: UIView!
    @IBOutlet weak var mainView: UIView!

    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.lineView.drawDashLine(lineLength: 1, lineSpacing: 2, lineColor: UIColor.init(hexString: "#C2C2C2"), isLevel: true)
        self.twoLineView.drawDashLine(lineLength: 1, lineSpacing: 2, lineColor: UIColor.init(hexString: "#C2C2C2"), isLevel: true)
        self.mainView.layer.cornerRadius = 5
        NotificationCenter.default.addObserver(self, selector: #selector(languageNotification), name: NSNotification.Name(rawValue: "languageNotification"), object: nil)

    }
    
    func setUI() {
        self.statisticsTitleLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_logistics_statistics)
        self.monthLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_senderInfo)
        self.storageLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_warehouse)
        self.dayLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_sender)
        self.dayFreightLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_freight)
        self.dayQuitLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_bounce)
        self.daycollectLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key:LanguageHeader.order_client_collection)
    }
    
    func setClientDic(clientDic:Dictionary<String, Any>) {
        self.clientDic = clientDic as Dictionary
        let num = String(self.clientDic["nearlyThirtySend"].debugDescription)
        self.monthNumLab.text = num
        self.storageNumLab.text = String(self.clientDic["warehousing"].debugDescription)
        self.dayNumLab.text = String(self.clientDic["todaySend"].debugDescription)
        self.dayFreightNumLab.text = String(self.clientDic["todayFreightAmount"].debugDescription)
        self.dayQuitNumLab.text = String(self.clientDic["todayReturn"].debugDescription)
        self.daycollecNumLab.text = String(self.clientDic["todayCollectionFreightAmount"].debugDescription)
    }
    
    @objc func languageNotification() {
        self.setUI()
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        self.delegate?.homeViewAcrionDelegate(actonType: HomeViewActonType.Home_EndEditingType)
        self.endEditing(true)
    }
}
